#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-

import sys
import os
import json
import re
import shutil
import zipfile
import time
from Core.makeNodesFile import *
from Common import *
# 当前路径
# .....python_test/MakeScript
currentpath = os.getcwd()


class BasicTemplate(object):

    def __init__(self, *zipfilepath):
        self.zipfilepath = zipfilepath
        self.outputpath = str(currentpath)+"/sticker/sticker"


        self.SpecificResourcePath = [""]
        self.srcContentFilePath = ""

    def CreateIndexAndMetadataJson(self):
        indexContent = ""
        indexContent = getSrcContent(self.srcContentFilePath, "")

        return indexContent

    def getOutPutPath(self):
        return self.outputpath



    # 基类
    # 解压zip生成Node类文件
    def createAndCopyNodesResource(self, zip,productName):
        makeNodesFile(self.outputpath, zip,productName)

    # 基类
    # 将特殊资源引入例如三宫格需要的palace.lua
    def CopySpecificResource(self):

        outPath = self.outputpath

        for i in range(0, len(self.SpecificResourcePath)):

            if os.path.isfile(self.SpecificResourcePath[i]):
                jsonPath = splitString(self.SpecificResourcePath[i], "/")
                outPath = outPath+"/"+jsonPath
                f = open(outPath, "w")
                f.close()
                shutil.copyfile(outPath,  self.SpecificResourcePath[i])
            elif os.path.isdir(self.SpecificResourcePath[i]):
                outPath = outPath+"/"
                copyDir(self.SpecificResourcePath[i], outPath)
            else:
                pass
    # 基类
    # 创建并写入lua文件内容
    def writeIntoLua(self,content):
        writeSymbolContentToLua(self.outputpath,content)
